#pragma once

#include <angelscript.h>
#include <engine.script/ContextPool.hpp>
#include <engine.script/System.hpp>


class Game;


/**
 * This class is a wrapper around an angelscript GameState interface implementation.
 * It merely delegates all calls to update to the actual implementation.
 */
class GameState
{
public:

	GameState(Game* game, Engine::Script::ContextPool::ptr contextPool, Engine::Script::pointer<asIScriptObject> object);



	/**
	 * Activates this game state.
	 */
	void activated();

	/**
	 * Deactivates this game state.
	 */
	void deactivated();

	/**
	 * Updates this game state.
	 * The actual implementation is up to the script writer.
	 */
	void update();



	/**
	 * Registers this class type with the script system.
	 */
	static void declareType(Engine::Script::System::ptr engine);
	static void registerType(Engine::Script::System::ptr engine);

private:

	Game*                                      m_game;

	Engine::Script::ContextPool::ptr           m_contextPool;
	Engine::Script::pointer<asIScriptObject>   m_object;

	int                                        m_activatedId;
	int                                        m_deactivatedId;
	int                                        m_updateId;
};
///////////////////////////////////////////////////////////////////////////////////////////////////
